<?php

namespace App\Http\Livewire;

use App\Models\Domain as DomainModel;
use Livewire\Component;

class Domain extends Component
{
    public $domain;
    public $searchString;
    public $view = 'main';

    public function mount($id)
    {
        $this->domain = DomainModel::findOrFail($id);
    }

    public function switchView($view)
    {
        $this->view = $view;
        $this->searchString = '';

        switch ($this->view) {
            case 'main':
                break;
            case 'chat':
                $this->domain->load('chatMessages');
                break;
            case 'users':
                $this->domain->load('users');
                break;
            case 'teams':
                $this->domain->load('teams');
                break;
            case 'hirings':
                $this->domain->load('hirings');
                break;
            case 'team-searches':
                $this->domain->load('teamSearches');
                break;
            case 'roles':
                $this->domain->load('roles');
                break;
        }
    }

    public function render()
    {
        return view('livewire.domain.domain');
    }
}
